package cn.lovefix.org.controller;
import cn.lovefix.base.pageList;
import cn.lovefix.org.domain.Novel;
import cn.lovefix.org.query.QueryNovel;
import cn.lovefix.org.query.queryByname;
import cn.lovefix.org.service.NovelService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
    @RestController
    @RequestMapping("/novel")
    public class NovelController {
        //删除用户
        @Autowired
        private NovelService novelService;
        @RequestMapping("/del")
        public String delete(@RequestParam Long id){
            System.out.println(id);
            novelService.del(id);
            return "ok";
        }
        //新增或者修改用户
        @RequestMapping("/update")
        public String addOrUpdate(@RequestBody Novel novel){
            if (novel.getId()==null){
                novelService.add(novel);
            }else {
                novelService.update(novel);
            }
            return "ok";
        }
        @ResponseBody
        @RequestMapping("/query")
        public pageList page(@RequestBody QueryNovel query){
            System.out.println(query.getKeyWord()+"我是keyWord");
            pageList<Novel> list = novelService.query(query);
            return list;
        }
    }


